package com.example.lzy.lzydemo;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import model.msgevent;
import model.toMainEvent;

public class BaseActivity1 extends AppCompatActivity {
    TextView txtview ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base1);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
//                        .setAction("Action", null).show();
                EventBus.getDefault().post(new toMainEvent("I am from base"));
            }
        });


        EventBus.getDefault().register(this);
       //txtview = (TextView)findViewById(R.id.txtShow);
    }

    @Subscribe
    public void onEvent(msgevent event)
    {/* Do something */
        //Toast.makeText(this,event.get_content(),Toast.LENGTH_LONG);
        txtview.setText(event.get_content());
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
